//给字体生成颜色
function generateRandomCode() {
    var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
    var code = '';
    for (var i = 0; i < 4; i++) {
        var index = Math.floor(Math.random() * characters.length);
        var char = characters.charAt(index);
        code += '<span>' + char + '</span>';
    }
    return code;
}

function generateCode() {
    var code = generateRandomCode(); // 生成新的验证码
    document.getElementById("code").innerHTML = code;
}





function checkLogin() {
    var enteredCodeValue = document.getElementById("enteredCode").value; // 得到前端输入的验证码
    var generatedCode = document.getElementById("code").textContent;
    var loginSuccess = false;
    if (enteredCodeValue === generatedCode) {
        loginSuccess = true;
    } else {
        alert("验证码错误");
        document.getElementById("enteredCode").value = "";
    }
    generateCode(); // 登录后重新生成验证码
    return loginSuccess;
}


